package training.service;
import java.util.Collection;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import training.controller.CustomerController;
import training.dao.CustomerDao;
import training.dao.SalesDao;
import training.vo.Customer;
import training.vo.Sales;
import baytony.db.Dao;
/**
 * @author fatsung
 *
 */
@Service("CustomerService")
@Transactional(propagation=Propagation.REQUIRED)
public class CustomerServiceImpl implements CustomerService{
	private static Logger log=LoggerFactory.getLogger(CustomerServiceImpl.class);
	@Autowired(required=true)
	@Qualifier("CustomerDao")
	private CustomerDao dao;
	@Autowired(required=true)
	@Qualifier("SalesDao")
	private Dao<Sales,String> dao1;

	@Override
	public Customer getCusById(String id) {
		// TODO Auto-generated method stub
		return dao.getById(id);
	}

	@Override
	public Sales getSalesByCustomerId(String id) {
		Customer cust = dao.findById(id);
		return dao1.findById(cust.getSalesId());
	}

	@Override
	public boolean updateCus(String id, String name, String password) {
		Customer cus = new Customer();
		cus.setId(id);
		cus.setName(name);
		cus.setPassword(password);
		dao.update(cus);
		return true;
	}

	@Override
	public void delete(Customer arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void delete(Collection<Customer> arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void save(Collection<Customer> arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void save(Customer arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void update(Collection<Customer> arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void update(Customer arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public List<Customer> findAll() {
		// TODO Auto-generated method stub
		return dao.findAll();
	}

	@Override
	public Customer findById(String arg0) {
		// TODO Auto-generated method stub
		return dao.findById(arg0);
	}

}
